package com.qiuhui.controller;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.qiuhui.entity.Blog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName: BlogController
 * @Description: TODO
 * @author: tian
 * @date: 2021/3/23  11:16 上午
 */
@Controller
public class BlogController {
    @RequestMapping("/json/date")
    // 不会经过视图解析器
    @ResponseBody
    public String getJsonDate() throws JsonProcessingException {
        Blog blog = new Blog("jean", "Spring MVC Framework学习.", 200000);
        String str = JSON.toJSONString(blog);
        return str;
    }
}
